/*
 * @Author: webcc
 * @Date: 2022-10-23 15:14:23
 * @LastEditTime: 2022-10-24 10:03:41
 * @email: webcc.coder@qq.com
 */
import request from 'utils/request'
/**
 * 获取文章列表
 * @returns 
 */
export const reqGetArticleList = (params) => {
    return request({
        url: '/mp/articles',
        method: 'GET',
        params
    })
}

/**
 * 删除文章
 * @param {string} id 
 * @returns 
 */
export const reqRemoveArticle = (id) => {
    return request({
        url: `/mp/articles/${id}`,
        method: 'DELETE',
    })
}

/**
 * 发布文章
 * @param {Object} data 
 * @returns 
 */
export const reqPublishArticle = (data, draft = false) => {
    return request({
        url: `/mp/articles?draft=${draft}`,
        data,
        method: 'POST',
    })
}

/**
 * 获取文章详情
 * @param {string} id 
 * @returns 
 */
export const reqGetArticleInfo = (id) => {
    return request({
        url: `/mp/articles/${id}`,
        method: 'GET',
    })
}

/**
 * 修改文章
 * @param {*} data 
 * @param {*} draft 
 * @returns 
 */
export const reqUpdateArticle = (data, draft = false) => {
    return request({
        url: `/mp/articles/${data.id}?draft=${draft}`,
        data,
        method: 'PUT',
    })
}